﻿package view.components.background 
{
	import org.casalib.display.CasaMovieClip;
		
	import gs.TweenLite;
	import gs.easing.*;
	
	/**
	 * ...
	 * @author Lobanov
	 */
	public class Line45Degree extends CasaMovieClip
	{
		
		public function Line45Degree() 
		{
			//nothing
		}
		
		public function startLine($w:Number, $h:Number, $color:int = 0x9c9a83):void 
		{
			this.removeChildren(true, true);
			
			for (var i:int = 1; i <= 15; i++) {
				this.addChild(new LineAcuteAngle());
				var line:CasaMovieClip = this.getChildAt(i - 1);
				moveLine(Math.floor(Math.random() * $h), line, 300+Math.floor(Math.random() * $w), 0, $color);
			}
		}
		
		private function moveLine($shiftY:Number, $line:CasaMovieClip, $x:Number, $y:Number, $color):void 
		{
			$line.x = $x;
			$line.y = $y;
			$line.alpha = 0;
			
			var newX:Number = $line.x - $shiftY;
			var newY:Number = $line.y + $shiftY;
			
			TweenLite.to($line, 2, { x:newX, y:newY, ease:Cubic.easeOut, tint:$color, alpha:.3 } );
			
			//0x4a8482 //news
			//0x834a84 //other bg = #271627
			//0x4A5184 //bg = #181827
			//0x51844a //bg = #1A2B17 - green
			//0x878747 // yallow
		}
		
	}

}